<template>
  <div>
    <h1>APP</h1>
    <TodoInput @addtask="addtask"></TodoInput>
    <TodoList :list="todolist"></TodoList>
  </div>
</template>

<script>
import TodoList from './components/todo-list/TodoList.vue'
import TodoInput from './components/todo-input/TodoInput.vue'

export default {
  name: 'MyApp',
  data() {
    return {
      todolist: [
        //任务列表数据
        { id: 1, task: '周一早上9点开会', done: false },
        { id: 2, task: '周一晚上吃法', done: false },
        { id: 3, task: '准备周三演讲稿', done: true },
      ],
    }
  },
  components: {
    TodoList,
    TodoInput,
  },
  methods: {
    addtask(val) {
      this.todolist.push({
        id: this.todolist.length + 1,
        task: val,
        done: false,
      })
    },
  },
}
</script>
<style lang="less" scoped></style>
